var querDetialUrl = "../loan/findById.action";

/*-------------------------页面加載------------------------------*/
var loadsoftDetInfo = function(data) {
	util.emmAjax({
		url : querDetialUrl,
		type : 'post',
		data : {
			'loanId' : data
		},
		cache : false,
		dataType : 'text',
		success : function(data) {
			var obj = util.str2Json(data); 
			if(obj.success=='true')
				{
					var object = util.str2Json(data).data.loanInfo;
					$("#borrowerName").html(object.borrowerName);
					//$("#spouseName").html(object.spouseName);
					var sexDesc;
					if(object.sex=="1")
					{
						sexDesc="男";
					}
					else if(object.sex=="2")
					{
						sexDesc="女";
					}
					else {
						sexDesc=object.sex;
					}
					$("#sex").html(sexDesc);
				    $("#credentialNo").html(object.credentialNo);
				    $("#isMaryed").html(object.isMaryed);
				    if(object.isMaryed=="是")
				    {
				    	$("#spouseInfo").show();
				    	 $("#spouseName").html(object.spouseName);
				    	 $("#spouseCredentialNo").html(object.spouseCredentialNo);
				    }
				    else if(object.isMaryed=="否")
				    {
				    	$("#spouseInfo").hide();
				    }
				    
				    
				    
				    var businessTypeDesc;
				    var remark1Desc="";
				    var remark2Desc="";
				    if(object.businessTypes=="1")
					{
				    	businessTypeDesc="一手房贷款";
				    	if(object.ysfRemark1=='1')
			    		{
				    		remark1Desc="一手住房贷款";
				    		remark2Desc=object.yszfRemark2;
			    		}
				    	else if(object.ysfRemark1=='2')
			    		{
				    		remark1Desc="商用房贷款";
				    		if(object.syfRemark2=="1")
			    			{
				    			remark2Desc="车位";
				    			//备注2位车位时不显示第几套房信息
				    			$("#houseNumNameTd").hide();
								$("#houseNumValueTd").hide();
			    			}
				    		else if (object.syfRemark2=="2")
			    			{
				    			remark2Desc="商铺、写字楼";
			    			}
			    		}
				    	else if(object.ysfRemark1=='3')
			    		{
				    		remark1Desc="职工或职工配偶贷款";
				    		$("#remark2Td").hide();
							$("#remark2Val").hide();
			    		}
				    	else
			    		{
				    		remark1Desc=object.syfRemark1;
				    		$("#remark2Td").hide();
							$("#remark2Val").hide();
			    		}
				    	$("#areaAndAmount").show();
						$("#numAndIncome").show();
						
						$("#payPerMon").show();
						$("#area").html(object.area);
						$("#houseAmount").html(object.houseAmount);
						var houseNumDesc="";
						if(object.houseNum=="1")
						{
							houseNumDesc="一套";
							
						}else if(object.houseNum=="2")
						{
							houseNumDesc="二套";
						}
						else if(object.houseNum=="3")
						{
							houseNumDesc="三套";
						}
						else if(object.houseNum=="4")
						{
							houseNumDesc="三套以上";
						}
						else{
							houseNumDesc=object.houseNum;
						}
						$("#houseNum").html(houseNumDesc);
						$("#income").html(object.income);
						$("#payPerMonth").html(object.payPerMonth);
						
					}
					else if(object.businessTypes=="2")
					{
						businessTypeDesc="二手房贷款";
						//remark1Desc="";
						if(object.esfRemark=='1')
			    		{
				    		remark1Desc="尊园地产推荐";
			    		}
				    	else if(object.esfRemark=='2')
			    		{
				    		remark1Desc="其他中介推荐";
			    		}
				    	else if(object.esfRemark=='3')
			    		{
				    		remark1Desc="职工或职工配偶贷款";
			    		}
				    	else
			    		{
				    		remark1Desc=object.esfRemark;
			    		}
						$("#remark2Td").hide();
						$("#remark2Val").hide();
						$("#areaAndAmount").show();
						$("#numAndIncome").show();
						$("#houseNumNameTd").show();
						$("#houseNumValueTd").show();
						$("#payPerMon").show();
						$("#area").html(object.area);
						$("#houseAmount").html(object.houseAmount);
						var houseNumDesc="";
						if(object.houseNum=="1")
						{
							houseNumDesc="一套";
							
						}else if(object.houseNum=="2")
						{
							houseNumDesc="二套";
						}
						else if(object.houseNum=="3")
						{
							houseNumDesc="三套";
						}
						else if(object.houseNum=="4")
						{
							houseNumDesc="三套以上";
						}
						else{
							houseNumDesc=object.houseNum;
						}
						$("#houseNum").html(houseNumDesc);
						
						$("#income").html(object.income);
						$("#payPerMonth").html(object.payPerMonth);
						
					}else if(object.businessTypes=="3")
					{
						businessTypeDesc="个人消费贷款";
						if(object.xfdkRemark=='1')
			    		{
				    		remark1Desc="个人消费贷款";
			    		}
				    	else if(object.xfdkRemark=='2')
			    		{
				    		remark1Desc="公职人员个人消费贷款";
			    		}
				    	else if(object.xfdkRemark=='3')
			    		{
				    		remark1Desc="公喜贷";
			    		}
				    	else if(object.xfdkRemark=='4')
			    		{
				    		remark1Desc="职工或职工配偶贷款";
			    		}
				    	else
			    		{
				    		remark1Desc=object.xfdkRemark;
			    		}
						$("#remark2Td").hide();
						$("#remark2Val").hide();
					}else if(object.businessTypes=="4")
					{
						businessTypeDesc="个人经营性贷款";
						if(object.jydkRemark1=='1')
			    		{
				    		remark1Desc="个人经营性贷款";
				    		$("#remark2Td").hide();
							$("#remark2Val").hide();
			    		}
				    	else if(object.jydkRemark1=='2')
			    		{
				    		remark1Desc="失业人员小额担保贷款";
				    		remark2Desc=object.syryRemark2;
			    		}
				    	else if(object.jydkRemark1=='3')
			    		{
				    		remark1Desc="“贷免扶补”创业小额贷款";
				    		remark2Desc=object.dmfbRemark2;
			    		}
				    	else if(object.jydkRemark1=='4')
			    		{
				    		remark1Desc="红色信贷";
				    		$("#remark2Td").hide();
							$("#remark2Val").hide();
			    		}
				    	else
			    		{
				    		remark1Desc=object.jydkRemark1;
				    		$("#remark2Td").hide();
							$("#remark2Val").hide();
			    		}
						
						//remark1Desc="";
					}else if(object.businessTypes=="5")
					{
						businessTypeDesc="农户小额信用贷款";
						$("#remark1Td").hide();
						$("#remark1Val").hide();
						$("#remark2Td").hide();
						$("#remark2Val").hide();
					}
					else {
						businessTypeDesc=object.businessTypes;
						$("#remark1Td").hide();
						$("#remark1Val").hide();
						$("#remark2Td").hide();
						$("#remark2Val").hide();
					}
				    
				    $("#businessTypes").html(businessTypeDesc);
				  
				    $("#remark1").html(remark1Desc);
				    
				    $("#remark2").html(remark2Desc);
				    $("#amount").html(object.amount);
					$("#term").html(object.term);
					var repaymentMethodDesc="";
					if(object.repaymentMethod=="1")
					{
						repaymentMethodDesc="等额本金";
						
					}else if(object.repaymentMethod=="2")
					{
						repaymentMethodDesc="等额本息";
					}
					else if(object.repaymentMethod=="3")
					{
						repaymentMethodDesc="循环用款";
					}
					else if(object.repaymentMethod=="4")
					{
						repaymentMethodDesc="到期还本";
					}
					else if(object.repaymentMethod=="5")
					{
						repaymentMethodDesc="分期还款";
					}
					else{
						repaymentMethodDesc=object.repaymentMethod;
					}
					$("#repaymentMethod").html(repaymentMethodDesc);
					$("#recieveTime").html(object.recieveTime);
					var guaranteeMethodDesc;
				    if(object.guaranteeMethod=="1")
					{
				    	guaranteeMethodDesc="信用";
					}
					else if(object.guaranteeMethod=="2")
					{
						guaranteeMethodDesc="保证";
					}else if(object.guaranteeMethod=="3")
					{
						guaranteeMethodDesc="抵押";
					}else if(object.guaranteeMethod=="4")
					{
						guaranteeMethodDesc="质押";
					}
					else {
						guaranteeMethodDesc=object.guaranteeMethod;
					}
					$("#guaranteeMethod").html(guaranteeMethodDesc);
					var isRenewDesc;
				    if(object.isRenew=="1")
					{
				    	isRenewDesc="新增";
					}
					else if(object.isRenew=="2")
					{
						isRenewDesc="续贷";
					}else if(object.isRenew=="3")
					{
						isRenewDesc="追加";
					}else if(object.isRenew=="4")
					{
						isRenewDesc="借新还旧";
					}
					else if(object.isRenew=="5")
					{
						isRenewDesc="展期";
					}
					else if(object.isRenew=="6")
					{
						isRenewDesc="重组贷款";
					}
					else {
						isRenewDesc=object.isRenew;
					}
					$("#isRenew").html(isRenewDesc);
					$("#marketer").html(object.marketer);
					var marketerPostDesc;
				    if(object.marketerPost=="1")
					{
				    	marketerPostDesc="白龙基社";
					}
					else if(object.marketerPost=="2")
					{
						marketerPostDesc="茨坝基社";
					}else if(object.marketerPost=="3")
					{
						marketerPostDesc="东华基社";
					}else if(object.marketerPost=="4")
					{
						marketerPostDesc="联盟基社";
					}
					else if(object.marketerPost=="5")
					{
						marketerPostDesc="龙泉基社";
					}
					else if(object.marketerPost=="6")
					{
						marketerPostDesc="龙头街基社";
					}
					else if(object.marketerPost=="7")
					{
						marketerPostDesc="营业部";
					}else if(object.marketerPost=="8")
					{
						marketerPostDesc="联社机关";
					}else if(object.marketerPost=="9")
					{
						marketerPostDesc="小微金融服务中心";
					}
					else if(object.marketerPost=="10")
					{
						marketerPostDesc="个金部营销组";
					}
					else if(object.marketerPost=="11")
					{
						marketerPostDesc="个金部管护组";
					}
					else if(object.marketerPost=="12")
					{
						marketerPostDesc="个金部一手房组";
					}
					else if(object.marketerPost=="13")
					{
						marketerPostDesc="个金部二手房组";
					}
					else if(object.marketerPost=="14")
					{
						marketerPostDesc="个金部不良组";
					}
					else if(object.marketerPost=="15")
					{
						marketerPostDesc="个金部部门员工";
					}
					else if(object.marketerPost=="16")
					{
						marketerPostDesc="金江分社员工";
					}
					else {
						marketerPostDesc=object.marketerPost;
					}
					$("#marketerPost").html(marketerPostDesc);
					$("#operator").html(object.operator);
					var operatorPostDesc;
				    if(object.operatorPost=="1")
					{
				    	operatorPostDesc="白龙基社";
					}
				    else if(object.operatorPost=="2")
					{
				    	operatorPostDesc="茨坝基社";
					}else if(object.operatorPost=="3")
					{
						operatorPostDesc="东华基社";
					}else if(object.operatorPost=="4")
					{
						operatorPostDesc="联盟基社";
					}
					else if(object.operatorPost=="5")
					{
						operatorPostDesc="龙泉基社";
					}
					else if(object.operatorPost=="6")
					{
						operatorPostDesc="龙头街基社";
					}
					else if(object.operatorPost=="7")
					{
						operatorPostDesc="营业部";
					}else if(object.operatorPost=="8")
					{
						operatorPostDesc="联社机关";
					}else if(object.operatorPost=="9")
					{
						operatorPostDesc="小微金融服务中心";
					}
					else if(object.operatorPost=="10")
					{
						operatorPostDesc="个金部营销组";
					}
					else if(object.operatorPost=="11")
					{
						operatorPostDesc="个金部管护组";
					}
					else if(object.operatorPost=="12")
					{
						operatorPostDesc="个金部一手房组";
					}
					else if(object.operatorPost=="13")
					{
						operatorPostDesc="个金部二手房组";
					}
					else if(object.operatorPost=="14")
					{
						operatorPostDesc="个金部不良组";
					}
					else if(object.operatorPost=="15")
					{
						operatorPostDesc="个金部部门员工";
					}
					else if(object.operatorPost=="16")
					{
						operatorPostDesc="金江分社员工";
					}
					else {
						operatorPostDesc=object.operatorPost;
					}
					$("#operatorPost").html(operatorPostDesc);
					//批复意见
					$("#curProcessFeedback").html(obj.data.curProcessFeedback);
					//审批金额
					$("#examineAmount").html(object.examineAmount);
					//审批期限
					$("#examineTerm").html(object.examineTerm);
					//审批担保方式
					var examineGuaranteeMethodDesc="";
					if(object.examineGuaranteeMethod=="1")
					{
						examineGuaranteeMethodDesc="信用";
						
					}else if(object.examineGuaranteeMethod=="2")
					{
						examineGuaranteeMethodDesc="保证";
					}
					else if(object.examineGuaranteeMethod=="3")
					{
						examineGuaranteeMethodDesc="抵押";
					}
					else if(object.examineGuaranteeMethod=="4")
					{
						examineGuaranteeMethodDesc="质押";
					}
					else{
						examineGuaranteeMethodDesc="";
					}
					$("#examineGuaranteeMethod").html(examineGuaranteeMethodDesc);
					//审批利率
					$("#examineRate").html(object.examineRate);
					//审批还款方式
					var examineRepaymentMethodDesc="";
					if(object.examineRepaymentMethod=="1")
					{
						examineRepaymentMethodDesc="等额本金";
						
					}else if(object.examineRepaymentMethod=="2")
					{
						examineRepaymentMethodDesc="等额本息";
					}
					else if(object.examineRepaymentMethod=="3")
					{
						examineRepaymentMethodDesc="循环用款";
					}
					else if(object.examineRepaymentMethod=="4")
					{
						examineRepaymentMethodDesc="到期还本";
					}
					else if(object.examineRepaymentMethod=="5")
					{
						examineRepaymentMethodDesc="分期还款";
					}
					else{
						examineRepaymentMethodDesc="";
					}
					$("#examineRepaymentMethod").html(examineRepaymentMethodDesc);
					
				}
			else
				{
					util.sysAlert(obj.data);
				}
		}
	});
};
/*
 * 获取url参数
 */
var getUrlParam=function(name) {
	 var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
	 var urlParam = window.location.search.substr(1);
	 var r = decodeURI(urlParam).match(reg);  //匹配目标参数
	 if (r != null) return unescape(r[2]); return null; //返回参数值

};

$(function(){
	var loanId = getUrlParam('loanId');
	loadsoftDetInfo(loanId);
	
});

/*$("#returnBtn").click(function(){
	window.location.href = "./loanAppCommit.html";
});*/